package xyf.p11.other;

/**
 * ClassName: P0058_LengthOfLastWord
 * Description:
 * Author: xyf
 * Date: 9/16/22 1:02 AM
 * Version: 1.0
 **/
public class P0058_LengthOfLastWord
{
    public int lengthOfLastWord(String s)
    {
        String str = s.trim();
        int i = str.length() - 1;
        while (i >= 0 && str.charAt(i) != ' ')
        {
            i--;
        }
        return str.length() - 1 - i;
    }
}
